package cn.com.surker.production.entity.report;

import cn.com.surker.base.ExportInter;
import cn.com.surker.excel.ExcelCell;
import cn.com.surker.production.entity.vo.ProductionIndentVo;
import cn.com.surker.production.entity.vo.ProductionInvoiceVo;
import cn.com.surker.util.MathUtils;
import cn.com.surker.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

/**
 * 发货单数据统计报表数据
 * 废弃不用
 *
 * @author luotao
 * @date 2024/12/5
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ProductionInvoiceReport extends ProductionIndentVo implements ExportInter {

	/**
	 * 发货单编号
	 */
	@ExcelCell(value = "发货单编号", sort = 1)
	private String invCode;

	/**
	 * 生产时间
	 */
	@ExcelCell(value = "生产时间", sort = 0, dateFormat = "YYYY-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date proTime;

	/**
	 * 累计生产方量
	 */
	@ExcelCell(value = "生产方量", sort = 8)
	private Double proStere;

	public Double getProStere() {
		//	生产方量
		if (!StringUtils.isNull(proStere))
			return StringUtils.formatDouble(proStere, 1);
		return 0.0;
	}
	/**
	 * 发货方量
	 */
	@ExcelCell(value = "发货方量", sort = 9)
	private Double sendStere;

	/**
	 * 砼方量
	 */
	@ExcelCell(value = "砼方量", sort = 10)
	private Double concreteStere;

	/**
	 * 砂浆方量
	 */
	@ExcelCell(value = "砂浆方量", sort = 11)
	private Double mortarStere;

	/**
	 * 水方量
	 */
	@ExcelCell(value = "水方量", sort = 12)
	private Double waterStere;

	/**
	 * 工地签收方量
	 */
	@ExcelCell(value = "工地签收方量", sort = 13)
	private Double signStere;

	/**
	 * 工地实际使用方量,
	 * 计算方式:实际生产方量+转入方量-过磅退回方量
	 */
	@ExcelCell(value = "工地实际使用方量", sort = 14)
	private Double realUseStere;

	public Double getRealUseStere() {
		//	总方量
		Double totalStere = MathUtils.add(getProStere(), getInStere());
		//	退回方量
		realUseStere = MathUtils.subtract(totalStere, getWeightReStere());
		return realUseStere;
	}

	/**
	 * 过磅退回方量
	 */
	@ExcelCell(value = "过磅退回方量", sort = 15)
	private Double weightReStere;

	/**
	 * 客户退回方量
	 */
	@ExcelCell(value = "客户退回方量", sort = 16)
	private Double buildReStere;

	/**
	 * 退回量差
	 * 计算方式
	 */
	@ExcelCell(value = "退回量差", sort = 17)
	private Double reDiffStere;

	/**
	 * 施工方退回已签方量
	 * 计算方式:签收方量-实际退回方量
	 */
	@ExcelCell(value = "退回已签", sort = 18)
	private Double buildReSign;

	public Double getBuildReSign() {
		Double signStere = getSignStere();
		Double realUseStere = getRealUseStere();
		buildReSign = MathUtils.subtract(signStere, realUseStere);
		return buildReSign;
	}

	/**
	 * 施工方退回未签
	 * 计算方式:退回方量-签收方量
	 */
	@ExcelCell(value = "退回未签", sort = 19)
	private Double buildReNoSign;

	public Double getBuildReNoSign() {
		Double buildReStere = getBuildReStere();
		if (buildReStere == null) {
			//	如果没有退回方量,则不存在退回未签
			return 0d;
		}
		Double signStere = getSignStere();
		buildReNoSign = MathUtils.subtract(buildReStere, signStere);
		return buildReNoSign;
	}

	/**
	 * 转入方量
	 */
	@ExcelCell(value = "转入方量", sort = 20)
	private Double inStere;

	/**
	 * 转出方量
	 */
	@ExcelCell(value = "转出方量", sort = 21)
	private Double outStere;

	/**
	 * 作废方量
	 */
	@ExcelCell(value = "作废方量", sort = 22)
	private Double scrapStere;

	/**
	 * 运输或者泵送结算方量,计算方式为小票发货方量-过磅退回方量
	 */
	@ExcelCell(value = "车队结算方量", sort = 23)
	private Double carBillStere;

	public Double getCarBillStere() {
		carBillStere = MathUtils.subtract(sendStere, weightReStere);
		return carBillStere;
	}

	/**
	 * 累计车次
	 */
	private Integer carTotal;

	/**
	 * 生产线
	 */
	private String lineName;

	/**
	 * 小票抬头
	 */
	private String receiptUnit;
	/**
	 * 发货单总数
	 */
	private Integer invoiceTotal;

	private List<ProductionInvoiceVo> invoiceList;

}
